package goliath;

import pulpcore.sprite.Group;
import pulpcore.sprite.Label;
import pulpcore.sprite.FilledSprite;
import pulpcore.image.Colors;
import org.jbox2d.dynamics.Body;

/**
 * @author will
 * @date Aug 9, 2008 7:31:57 PM
 */
public class BodyInfoBox extends Group {
    Group labelGroup;
    Label labelText;
    Label material1;
    Label material2;
    Body b;
    FilledSprite background = new FilledSprite(0, 0, 40, 40, Colors.WHITE);

    public BodyInfoBox(Body b) {
        super();
        this.b = b;
        this.add(background);
/*
        labelText = Label.createMultilineLabel("Body:\n(" + b.getXForm().position.x + ","
                + b.getXForm().position.y + ")", 0, 0);
        add(labelText);
*/
        double y = 0;
        labelGroup = new Group();
        labelText = new Label("Body:" + b.getXForm().position.x+","+
                b.getXForm().position.y, 0, 0);
        labelGroup.add(labelText);

        y+=labelText.height.get();
        material1 = new Label("Mass:",0,y);
        labelGroup.add(material1);
        labelGroup.pack();

        background.bindSizeTo(labelGroup);
        add(labelGroup);
    }

    public void update(int elapsedTime) {
        super.update(elapsedTime);

        labelText.setText("Body:" + b.getXForm().position.x+","+
                b.getXForm().position.y);
        material1.setText("Mass:"+b.getMass());
    }
}
